﻿using System.Linq;
using Fee.Orders;

namespace Fee.ViewModel
{
    public class BudgetViewModel
    {
        public BudgetViewModel(ConstructionTask task, ConstructionTaskPlanCost planCost)
        {
            Station = new StationViewModel(task.Station);
            Project = task.Details.First().Project;
            this.Type = planCost.Type;
            foreach (var detail in task.Details)
            {
                if (detail.ConstructionType == planCost.Type)
                {
                    switch (detail.ContractType)
                    {
                        case ContractType.Design:
                            DesignContract = detail.Contract;
                        
                            break;
                        case ContractType.Supervisor:
                            SupervisorContract = detail.Contract;
                        
                            break;
                        case ContractType.Construction:
                            ConstructionContract = detail.Contract;
                       
                            break;
                    }
                }

                this.Cost = planCost;
            }

            

        }
        public ConstructionType Type { get; set; }
        public FrameworkContract DesignContract { get; set; }
        public FrameworkContract SupervisorContract { get; set; }
        public FrameworkContract ConstructionContract { get; set; }
        public Project Project { get; set; }
        public StationViewModel Station { get; set; }

        public ConstructionTaskPlanCost Cost { get; set; }

    }
}
